﻿<base:AbstractDialogContentControl x:Class="Deployment.Data.UI.Controls.Task.AddTaskControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:base="clr-namespace:Deployment.Data.UI.Dialogs"
             xmlns:tasks="clr-namespace:Deployment.Data.Deploy.Steps.Tasks;assembly=Deployment.Data"
             xmlns:t="clr-namespace:Deployment.Data.UI.Controls.Task"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300"
             MinHeight="300" MinWidth="300"
            >
    <UserControl.Resources>
        <ObjectDataProvider x:Key="comboDataSource"
                            ObjectType="{x:Type tasks:AbstractTask}"
                            MethodName="GetAvailableTaskTypes"/>
    </UserControl.Resources>
    <UserControl.Style>
        <Style>
            
        </Style>
    </UserControl.Style>
    <DockPanel LastChildFill="True" Margin="4">
        <Grid DockPanel.Dock="Top">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto"/>
                <ColumnDefinition Width="*"/>
            </Grid.ColumnDefinitions>
            
            <Label Grid.Column="0"
                   Content="Select task type:"
                   VerticalAlignment="Center"
                   Margin="2"
                   Padding="2"/>
            
            <ComboBox Grid.Column="1"
                      ItemsSource="{Binding Source={StaticResource comboDataSource}}"
                      DisplayMemberPath="TypeDescription"
                      x:Name="TypeCombo" Height="24" VerticalAlignment="Bottom"
                      />
                      
        </Grid>
        <CheckBox x:Name="okContentCheckbox"
                  IsChecked="{Binding ElementName=EditorControl, Path=isContentOk}"
                  Visibility="Collapsed"
                  Checked="okContentCheckbox_Checked"/>
        <t:TaskEditorControl x:Name="EditorControl" 
                             DockPanel.Dock="Bottom"
                             DataContext="{Binding ElementName=TypeCombo, Path=SelectedValue}"
                             DataContextChanged="EditorControl_DataContextChanged"
                             Margin="4,4,4,0" Loaded="EditorControl_Loaded">
            <t:TaskEditorControl.Style>
                <Style>
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding ElementName=TypeCombo, Path=SelectedValue}"
                                     Value="{x:Null}">
                            <Setter Property="t:TaskEditorControl.IsEnabled"
                                    Value="False"/>
                        </DataTrigger>
                    </Style.Triggers>
                </Style>
            </t:TaskEditorControl.Style>
        </t:TaskEditorControl>
            
            
    </DockPanel>
</base:AbstractDialogContentControl>
